package com.javacommunity.model.entity;

// Generated Nov 25, 2014 11:55:44 PM by Hibernate Tools 3.4.0.CR1

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "comment", catalog = "db_javadanang")
public class Comment implements java.io.Serializable {

    private Integer commentId;
    private User user;
    private Post post;
    private Date createDate;
    private Date updateDate;
    private String content;

    public Comment() {
    }

    public Comment(User user, Post post, Date createDate, String content) {
        this.user = user;
        this.post = post;
        this.createDate = createDate;
        this.content = content;
    }

    public Comment(User user, Post post, Date createDate, Date updateDate,
            String content) {
        this.user = user;
        this.post = post;
        this.createDate = createDate;
        this.updateDate = updateDate;
        this.content = content;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "commentId", unique = true, nullable = false)
    public Integer getCommentId() {
        return this.commentId;
    }

    public void setCommentId(Integer commentId) {
        this.commentId = commentId;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @Fetch (FetchMode.SELECT)
    @JoinColumn(name = "userId", nullable = false)
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @Fetch (FetchMode.SELECT)
    @JoinColumn(name = "postId", nullable = false)
    public Post getPost() {
        return this.post;
    }

    public void setPost(Post post) {
        this.post = post;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "createDate", nullable = false, length = 10)
    public Date getCreateDate() {
        return this.createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "updateDate", length = 10)
    public Date getUpdateDate() {
        return this.updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    @Column(name = "content", nullable = false, length = 65535)
    public String getContent() {
        return this.content;
    }

    public void setContent(String content) {
        this.content = content;
    }

}
